package org.pzy.pulsar;

import org.apache.pulsar.client.api.*;

/**
 * @author pzy
 */
public class PubDemo {
    public static void main(String[] args) throws PulsarClientException {

        PulsarClient client = PulsarClient.builder()
                .serviceUrl("pulsar://192.168.56.101:6650")
                .build();
        Producer<byte[]> producer = client.newProducer()
                .topic("topic-20240320")
                .create();
        for (int i = 0; i < 20; i++) {
            MessageId messageId = producer.send(("你好" + i).getBytes());
            System.out.println("发送成功：messageId=" + messageId);
        }

    }
}
